{extend name="public/base"/}
{block name="body"}
<style>
	ul.ztree {
		margin-top: 10px;
		border: 1px solid #617775;
		background: #f0f6e4;
		width: 220px;
		height: 320px;
		overflow-y: scroll;
		overflow-x: auto;
</style>
<div class="main-box clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-left">
			<h2>{$meta_title}</h2>
		</div>
	</header>
	<div class="main-box-body clearfix">
		<form method="post" class="form form-horizontal" action="__URL__/processingBatch" id="form" enctype="multipart/form-data">
			<div class="form-group">
				<label class="col-lg-2 control-label"></label>
				<div class="col-lg-2">
					<div class="radio radio-nice radio-inline">
						<input type="radio" name="batchtype" id="1" value="1" checked/>
						<label for="1">批量导入</label>
					</div>
					<div class="radio radio-nice radio-inline">
						<input type="radio" name="batchtype" id="2" value="2"/>
						<label for="2">批量翻译</label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-lg-2 control-label">文件夹路径</label>
				<div class="col-lg-2">
					<ul id="treeDemo" class="ztree"></ul>
					<!--<input type="text" class="form-control" name="url" id="url" value="" >
					<label for="url">windows下例如 d:\mopo linux下例如 /mopo</label>-->
				</div>

			</div>
			<div class="form-group" id="upload">
				<label class="col-lg-2 control-label">标准翻译</label>
				<div class="col-lg-2">
					<div class="radio radio-nice radio-inline">
						<input type="radio" name="flag" id="flag0" value="0" checked/>
						<label for="flag0">否</label>
					</div>
					<div class="radio radio-nice radio-inline">
						<input type="radio" name="flag" id="flag1" value="1"/>
						<label for="flag1">是</label>
					</div>
				</div>
			</div>
			<div class="form-group" id="translate" style="display: none">
				<label class="col-lg-2 control-label">翻译其他语种</label>
				<div class="col-lg-2">
					<div class="radio radio-nice radio-inline">
						<input type="radio" name="language" id="language0" value="0" checked/>
						<label for="language0">否</label>
					</div>
					<div class="radio radio-nice radio-inline">
						<input type="radio" name="language" id="language1" value="1"/>
						<label for="language1">是</label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<div class="col-lg-offset-2 col-lg-10">
					<button class="btn btn-success submit-btn" type="button" id="button">确 定</button>
				</div>
			</div>
		</form>

	</div>
</div>
{/block}


{block name="script"}
<script type="text/javascript">
	var setting = {
		async: {
			enable: true,
			url:"__URL__/geturllist",
			autoParam:["id", "name=n", "level=lv"],
			otherParam:{"otherParam":"0"},
			dataFilter: filter
		}
	};
	function filter(treeId, parentNode, childNodes) {
		if (!childNodes) return null;
		for (var i=0, l=childNodes.length; i<l; i++) {
			childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
		}
		return childNodes;
	}
	var tree=$.fn.zTree.init($("#treeDemo"), setting);

	//修改每页显示数量
	$("input[name='batchtype']").change(function(){
		if($(this).val()==2){
			$("#translate").show();
			$("#upload").hide();
		}else{
			$("#translate").hide();
			$("#upload").show();
		}
	});
	$("#button").click(function(){
		var jsonArrayFinal = tree.getSelectedNodes();
		var url=jsonArrayFinal[0].id;
		var batchtype=$("input[name='batchtype']:checked").val();
		var flag=$("input[name='flag']:checked").val();;
		var language=$("input[name='language']:checked").val();;
		$(this).attr('disabled',"disabled");
		$(this).html("处理中");
		$.ajax({
			url:"/admin/msgset/processingBatch",
			data:{batchtype:batchtype,url:url,flag:flag,language:language},
			dataType:'json',
			type:'post',
			success:function(re){
				if(re.error==0){
					alert(re.msg);
				}else {
					alert(re.msg);
				}
				$("#button").removeAttr("disabled");
				$("#button").html("确 定");
			}
		})
	});
</script>
{/block}
